//
//  BaseRequest.m
//  喝喝
//
//  Created by LiJonius on 15/9/29.
//  Copyright (c) 2015年 com.hehe. All rights reserved.
//

#import "BaseRequest.h"
#import "AFHTTPRequestOperationManager.h"
static BaseRequest* request;
@implementation BaseRequest
+(instancetype)shareCCRequest{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        request=[[BaseRequest alloc]init];
    });
    return request;
}

-(void)loadDatWithUrl:(NSString *)url andParameters:(NSDictionary *)parameters andCallBackSuccess:(CallBackSuccess)completeSuccess andCallBaceFaild:(CallBackFaild)completeFaild{
    [[self getManager] POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        completeSuccess(responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        completeFaild(error);
    }];
    
}
//获取请求对象
-(AFHTTPRequestOperationManager*)getManager
{
    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
    //manager.requestSerializer = [AFJSONRequestSerializer serializer];
    //manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    return manager;
}
@end
